//
//  ATScreenAdapter.h
//  ABCTime
//
//  Created by MCKing on 2017/11/13.
//  Copyright © 2017年 100TAL. All rights reserved.
//

#import <Foundation/Foundation.h>

#import <UIKit/UIKit.h>

/// 手机类型
typedef enum : NSUInteger {
    
    DeviceTypeIphone4s,
    
    DeviceTypeIphone5,
    
    DeviceTypeIphone6,
    
    DeviceTypeIphone6p,
    
    DeviceTypeIphoneX,
    
} DeviceType;

/**
 屏幕适配器
 */
@interface ATScreenAdapter : NSObject

/**
 设置默认机型 默认是 DeviceTypeIphone6
 */
+ (void) setDeviceType:(DeviceType)type;

+ (CGFloat) screenWidth;

+ (CGFloat) screenHeight;

/**
 屏幕比例
 */
+ (CGFloat) screenRate;

@end


/* Make a float from a. */

CG_INLINE CGFloat ATFloat(CGFloat a);
CG_INLINE CGSize ATImageSize(UIImage *image);
CG_INLINE CGSize ATSize(CGSize size);

/* Make a rect from `(x, y; width, height)'. */
CG_INLINE CGRect ATRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height);

/* Make a size from `(width, height)'. */
CG_INLINE CGSize ATSizeMake(CGFloat width, CGFloat height);

/* Make a point from `(x, y)'. */
CG_INLINE CGPoint ATPointMake(CGFloat x, CGFloat y);

CG_INLINE CGFloat
ATFloat(CGFloat a) {
    return a * [ATScreenAdapter screenRate];
}

CG_INLINE CGSize
ATImageSize(UIImage *image) {
    return (CGSize){ATFloat(image.size.width * 2), ATFloat(image.size.height * 2)};
}


CG_INLINE CGSize
ATSize(CGSize size) {
    return (CGSize){ATFloat(size.width * 2), ATFloat(size.height * 2)};
}

CG_INLINE CGRect
ATRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
    CGRect rect;
    rect.origin.x = ATFloat(2 * x);
    rect.origin.y = ATFloat(2 * y);
    rect.size.width = ATFloat(2 * width);
    rect.size.height = ATFloat(2 * height);
    return rect;
}

CG_INLINE CGSize
ATSizeMake(CGFloat width, CGFloat height)
{
    CGSize size;
    size.width = ATFloat(2 * width);
    size.height = ATFloat(2 * height);
    return size;
}

CG_INLINE CGPoint
ATPointMake(CGFloat x, CGFloat y)
{
    CGPoint p;
    p.x = ATFloat(2 * x);
    p.y = ATFloat(2 * y);
    return p;
}
